home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / MotifApp / ch9 / MenuDemoApp.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-03  |  2.5 KB  |  78 lines

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //////////////////////////////////////////////////////////////////////////////
  3. //         This example code is from the book:
  4. //
  5. //           Object-Oriented Programming with C++ and OSF/Motif
  6. //         by
  7. //           Douglas Young
  8. //           Prentice Hall, 1992
  9. //           ISBN 0-13-630252-1    
  10. //
  11. //         Copyright 1991 by Prentice Hall
  12. //         All Rights Reserved
  13. //
  14. //  Permission to use, copy, modify, and distribute this software for 
  15. //  any purpose except publication and without fee is hereby granted, provided 
  16. //  that the above copyright notice appear in all copies of the software.
  17. ///////////////////////////////////////////////////////////////////////////////
  18. //////////////////////////////////////////////////////////////////////////////
  19.  
  20.  
  21. ///////////////////////////////////////////////////////////////
  22. // MenuDemoApp.C:
  23. //////////////////////////////////////////////////////////////
  24. #include "MenuDemoApp.h"
  25. #include "QuitCmd.h"
  26. #include "ManageCmd.h"
  27. #include "IconifyCmd.h"
  28. #include "NoOpCmd.h"
  29. #include "MenuDemoWindow.h"
  30.  
  31. MenuDemoApp *theMenuDemoApp = new MenuDemoApp ( "MenuDemo" );
  32. MainWindow  *window1 = new MenuDemoWindow ( "Window1" );
  33. MainWindow  *window2 = new MenuDemoWindow ( "Window2" );
  34. MainWindow  *window3 = new MenuDemoWindow ( "Window3" );
  35.  
  36. MenuDemoApp::MenuDemoApp ( char * name ) : Application ( name )
  37. {
  38.     // Create the application-wide commands that appear in all menus
  39.     
  40.     _quit    = new QuitCmd ( "Quit" , TRUE );
  41.     _manage  = new ManageCmd ( "Open", TRUE );
  42.     _iconify = new IconifyCmd ("Iconify", TRUE );
  43.     
  44.     // Create three NoOpCmd objects to demonstrate dependencies and
  45.     // to demo the support for multiple interfaces to a single Cmd.
  46.     // Start X and Y as active, Z as inactive.
  47.     
  48.     _x = new NoOpCmd ( "X", TRUE );
  49.     _y = new NoOpCmd ( "Y", TRUE );
  50.     _z = new NoOpCmd ( "Z", FALSE );
  51.     
  52.     // Specify relationships between the X, Y, and Z commands
  53.     // Activating any command deactivates itself and activates
  54.     // the other two commands
  55.     
  56.     _x->addToActivationList ( _y );
  57.     _x->addToActivationList ( _z );
  58.     _x->addToDeactivationList ( _x );
  59.     
  60.     _y->addToActivationList ( _x );
  61.     _y->addToActivationList ( _z );
  62.     _y->addToDeactivationList ( _y );
  63.     
  64.     _z->addToActivationList ( _x );
  65.     _z->addToActivationList ( _y );
  66.     _z->addToDeactivationList ( _z );
  67. }
  68.  
  69. MenuDemoApp::~MenuDemoApp()
  70. {
  71.     delete _quit;
  72.     delete _manage;
  73.     delete _iconify;
  74.     delete _x;
  75.     delete _y;
  76.     delete _z;
  77. }
  78.